<?php

class TweetsModel extends RelationModel {
	/*
	 * 定义关联关系
	 */

	protected $_link = array(
		'user' => array(
			'mapping_type' => BELONGS_TO,
			'class_name' => 'user',
			'foreign_key' => 'user_id',
		),
		'school' => array(
			'mapping_type' => BELONGS_TO,
			'class_name' => 'school',
			'foreign_key' => 'school_id',
		),
		'location' => array(
			'mapping_type' => BELONGS_TO,
			'class_name' => 'location',
			'foreign_key' => 'location_id',
			'as_fields' => 'location_id,location_name,location_point',
		),
		'comment' => array(
			'mapping_type' => HAS_MANY,
			'class_name' => 'comment',
			'foreign_key' => 'tweets_id',
			'mapping_order' => 'comment_id asc',
		),
	);

	/*
	 * 表单数据验证 
	 */
	protected $_validate = array(
		array('content', 'require', '内容不能为空'),
	);
	/*
	 * 数据自动完成 
	 */
	protected $_auto = array(
		array('create_time', 'time', 1, 'function'),
	);

	/*
	 * 表单项与字段的映射
	 */
}

?>
